(function($){
    window.Dialog = {
        alert : function(msg){
            if($("#dialogMsg").length<=0){
                $("body").append(alertDialog);
            }
            $("#dialogMsg").html(msg);
            $('#dialogDiv').modal({backdrop:false});
        },
        loading : function(msg){
            if($("#loadingDiv").length<=0){
                $("body").append(loadingDialog);
            }
            $('#loadingDiv').modal({backdrop:false});
        },
        prompt:function(options){
            if($("#promptDialog").length<=0){
                $("body").append(promptDialog);
            }
            if(options.title){
                $("#promptTitle").html(options.title);
            }
           // $("#promptCon").val("");
            $('#promptDialog').modal({backdrop:false});
            $("#promptOk").unbind("click");
            $("#promptOk").on("click",function(){
                var remark = $.trim($("#promptCon").val());
                if(remark==""){
                    window.Dialog.alert("请输入备注信息!")
                    return ;
                }
                $('#promptDialog').modal('hide')
                options.func(remark);
            });
        },
        closeLoading : function(){
            $('#loadingDiv').modal('hide')
        }
    };


    var promptDialog = '<div class="modal fade" id="promptDialog">'+
    '<div class="modal-dialog">'+
    '<div class="modal-content">'+
    ' <div class="modal-header">'+
    '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
    '<h4 class="modal-title" id="promptTitle">提示信息</h4>'+
    '</div>'+
    '<div class="modal-body">'+
    '<textarea class="form-control" rows="3" placeholder="请输入内容" id="promptCon"></textarea>'+
    '</div>'+
    '<div class="modal-footer">'+
    '<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>'+
    '<button type="button" class="btn btn-primary" id="promptOk">确定</button>'+
    '</div>'+
    '</div>'+
    '</div>'+
    '</div>';

    var alertDialog = '<div class="modal fade" id="dialogDiv">'+
        '<div class="modal-dialog">'+
        '<div class="modal-content">'+
        ' <div class="modal-header">'+
        '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>'+
        '<h4 class="modal-title" id="dialogTitle">提示信息</h4>'+
        '</div>'+
        '<div class="modal-body">'+
        '<p><span id="dialogMsg"></span></p>'+
        '</div>'+
        '<div class="modal-footer">'+
        '<button type="button" class="btn btn-default" data-dismiss="modal">确定</button>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>';


    var loadingDialog = '<div class="modal fade" id="loadingDiv">'+
        '<div class="modal-dialog">'+
        '<div class="modal-content">'+
        ' <div class="modal-header text-center">数据正在处理！请耐心等待！'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>';
})(jQuery);